<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>测试</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<%--<form action="GetAllNewsServlet" method="post">
    <input type="text" value="${keyword}" placeholder="请输入搜索关键字" name="keyword" size="50"> <input type="submit" value="搜">
</form>
<table border="1">
    <tr>
        <th>编号</th>
        <th>标题</th>
        <th>所属版块</th>
        <th>发布时间</th>
        <th>发布人</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${newsList}" var="n">
        <tr>
            <th>${n.newsid}</th>
            <th>${n.title}</th>
            <th>${n.blockItem.bitemname}</th>
            <th>${n.pushtime}</th>
            <th>${n.user.username}</th>
            <th>操作</th>
        </tr>
        <br>
    </c:forEach>
</table>
<br> 共${sumnews}条记录共${sumpages}页 当前第${pageno}页
<a href="GetAllNewsServlet?pageno=1&keyword=${keyword}">首页</a>
<a href="GetAllNewsServlet?pageno=${pageno+1}&keyword=${keyword}">下一页</a>
<a href="GetAllNewsServlet?pageno=${pageno-1}&keyword=${keyword}">上一页</a>
<a href="GetAllNewsServlet?pageno=${sumpages}&keyword=${keyword}">尾页</a>--%>
<%----%>
<ul class="nav nav-tabs" id="block">
    <li class="active"><a href="#">Home</a></li>
    <c:forEach items="${blockList}" var="b">
        <li class="dropdown" onclick="A(${b.blockid})">
            <a class="dropdown-toggle" data-toggle="dropdown">
                    ${b.blockname}
                        <span class="caret"></span>
            </a>
            <ul class="dropdown-menu"></ul>
        </li>
    </c:forEach>
</ul>
</body>
</html>
<script>
    function A(num) {
        $.ajax({
            type: "POST",
            url: "GetblockItemServlet",
            dataType: 'JSON',
            data:{
                blockid:num,
            },
            success: function (data){
                if (data != null){
                    $(".dropdown-menu").html("");
                    if (data != null) {
                        $.each(data, function (index, obj) {
                            var block ="<li>"+"<a href='#'>"+obj.bitemname+"</a>"+"</li>";
                            $(".dropdown-menu").append(block);
                        })
                    }
                }
            }
        })
    }
</script>
